package io.api.modules.login.controller;

import io.admin.common.utils.Result;
import io.api.annotation.Pass;
import io.api.modules.login.dto.EditionDTO;
import io.api.modules.login.service.EditionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 版本管理
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2024-07-08
 */
@RestController
@RequestMapping("/api/edition")
@AllArgsConstructor
@Api(tags="版本管理")
public class EditionController {
    private final EditionService editionService;

    @Pass
    @GetMapping
    @ApiOperation("信息")
    public Result get(@RequestParam(value = "type", required = false) Integer type){
        // 检查是否最新版本
        EditionDTO data = editionService.selectNewest(type);
        if (data == null) {
            return new Result<Map<String, Object>>().error(10001,"找不到对应版本");
        }
        return new Result<EditionDTO>().ok(data);
    }

}